<?php
class GoodsCheck extends Check {

    public function addCheck(Model &$model,Array $condition=array()) {
        if(self::checkStrEqual($_POST['nav'],-1)) {
            $this->flag = false;
            $this->message[] = '请务必选择一个商品类别!';
        }
        if(self::checkStrEqual($_POST['brand'],-1)) {
            $this->flag = false;
            $this->message[] = '请务必选择一个商品品牌!';
        }
        if(self::isNullString($_POST['name'])) {
            $this->flag = false;
            $this->message[] = '商品名称不能为空!';
        }
        if(self::checkStrLength($_POST['name'],2,'min')) {
            $this->flag = false;
            $this->message[] = '商品名称不能少于两位!';
        }
        if(self::checkStrLength($_POST['name'],100,'max')) {
            $this->flag = false;
            $this->message[] = '商品名称不能大于一百位!';
        }
        if(self::isNullString($_POST['sn'])) {
            $this->flag = false;
            $this->message[] = '商品编号不能为空!';
        }
        if(self::checkStrLength($_POST['sn'],2,'min')) {
            $this->flag = false;
            $this->message[] = '商品编号不能少于两位!';
        }
        if(self::checkStrLength($_POST['sn'],100,'max')) {
            $this->flag = false;
            $this->message[] = '商品编号不能大于一百位!';
        }
        if($model->isOne($condition)) {
            $this->flag = false;
            $this->message[] = '商品编号已被占用!';
        }
        return $this->flag;
    }

    public function updateCheck(Model &$model,Array $condition) {
        return $this->addCheck($model,$condition);
    }


}


?>